package com.changgou.controller;

import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.service.SkuSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/manager")
public class ESManagerController {

    @Autowired
    private SkuSearchService skuSearchService;

    /**
     * 创建索引库
     * @return
     */
    @GetMapping("/create")
    public Result create(){
        skuSearchService.createIndexAndMapping();
        return new Result(true, StatusCode.OK,"创建索引库成功!");
    }


    @GetMapping("/importAll")
    public Result importAll(){
        skuSearchService.importAll();
        return new Result(true,StatusCode.OK,"全部数据导入成功!");
    }


}
